﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Playlist_file_loader.Core
{
    struct ErrorMsg
    {
        //-------------------------------------------------------------------//
        //-------------------------member variables--------------------------//
        //-------------------------------------------------------------------//
        private String m_strErrorText;

        //-------------------------------------------------------------------//
        //-------------------------function definitions----------------------//
        //-------------------------------------------------------------------//

        //-------------------------------------------------------------------//
        // Description: ...
        public ErrorMsg(String strErrMsg)
        {
            m_strErrorText = strErrMsg;
        }

        //-------------------------------------------------------------------//
        // Description: ...
        public String GetErrString()
        {
            return m_strErrorText;
        }
    }


    class ErrorMgmt
    {
        //-------------------------------------------------------------------//
        //-------------------------member variables--------------------------//
        //-------------------------------------------------------------------//
        private static Core.ErrorLogUpdater m_ErrorLogUpdater;
        private static MainForm m_MainForm;

        //-------------------------------------------------------------------//
        //-------------------------function definitions----------------------//
        //-------------------------------------------------------------------//


        //-------------------------------------------------------------------//
        // Description: ...
        public static void Add( ErrorMsg errorMsg )
        {
            if (null != m_MainForm)
            {
                if (null != m_ErrorLogUpdater)
                {
                    // Inform Errorlog as well
                    m_MainForm.BeginInvoke(m_ErrorLogUpdater.methodAddItemToListBox, new Object[] { errorMsg });
                }

                // May add to file log
                // ..
            }
            
        }

        //-------------------------------------------------------------------//
        // Description: ...
        public static void ConnectMainForm(MainForm mainForm)
        {
            m_MainForm = mainForm;
        }

        //-------------------------------------------------------------------//
        // Description: ...
        public static void ConnectErrorLogUpdater(Core.ErrorLogUpdater errorLogUpdater)
        {
            m_ErrorLogUpdater = errorLogUpdater;
        }
    }
}
